﻿/* DotNetHoldem 
 * .Net Solution that allows to use OpenHoldem with .Net logic
 * Author: Óscar Andreu
 * oesido at gmail dot com
 * Licensed under GPLv3 - 2012
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotNetBotLogic.Classes.Log;

namespace DotNetBotLogic.Classes.PlayHistory
{
    internal class PlayTracker
    {
        private List<Player> playerList;
        internal List<Player> PlayerList
        {
            get { return playerList == null ? new List<Player>() : playerList; }
            set { playerList = value; }
        }

        internal void RefreshPlayers()
        {
            Player player;
            string name;

            for (int i = 0; i < 10; i++)
            {
                name = OhHelper.GetPlayerName(i);

                player = PlayerList.Where(a => a.Name == name).FirstOrDefault();
                if (player == null)
                {
                    player = new Player(name);
                }
                player.CurrentChair = i;
                player.DealPosition = (int)OhHelper.GetSymbol(string.Format("ac_betpos{0}", i)); ;
                player.Balance = OhHelper.GetSymbol(string.Format("balance{0}", player.CurrentChair));

                Logger.Log(string.Format("PlayTracker -- {0} chair:{1} winloss: {2}", player.Name, player.CurrentChair, player.Winloss));
            }
        }
    }
}
